home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / ubiquity / apt-setup / generators / 50mirror.ubuntu < prev    next >
Encoding:
Text File  |  2009-02-24  |  6.9 KB  |  249 lines

  1. #!/bin/sh
  2. set -e
  3.  
  4. . /usr/share/debconf/confmodule
  5.  
  6. file="$1"
  7.  
  8. log() {
  9.     logger -t apt-setup "$@"
  10. }
  11. warning() {
  12.     log "warning: $@"
  13. }
  14.  
  15. # Ask if a mirror should be used if the base system can be installed from CD
  16. if [ -e /cdrom/.disk/base_installable ] || [ "$OVERRIDE_BASE_INSTALLABLE" ]; then
  17.     if ! search-path choose-mirror; then
  18.         warning "choose-mirror is not available; cannot offer network mirror"
  19.         exit 1
  20.     fi
  21.  
  22.     # Set default if no value (see Debian mirror generator)
  23.     db_get apt-setup/use_mirror
  24.     [ "$RET" ] || db_set apt-setup/use_mirror true 
  25.  
  26.     # Text is variable for Debian
  27.     db_metaget apt-setup/use/netinst_old description
  28.     db_subst apt-setup/use_mirror EXPLANATION "$RET"
  29.  
  30.     db_input medium apt-setup/use_mirror || [ $? -eq 30 ]
  31.     db_go # or exit 10
  32.  
  33.     db_get apt-setup/use_mirror
  34.     if [ "$RET" = false ]; then
  35.         exit 1
  36.     fi
  37.  
  38.     if db_get cdrom/codename && [ "$RET" ]; then
  39.         db_set mirror/codename $RET
  40.     fi
  41.     if db_get cdrom/suite && [ "$RET" ]; then
  42.         db_set mirror/suite $RET
  43.     fi
  44.     choose-mirror -n # no progress bar
  45. fi
  46.  
  47. STATE=1
  48. while :; do
  49.     case "$STATE" in
  50.         1)
  51.             db_input low apt-setup/restricted || true
  52.         ;;
  53.         2)
  54.             db_input low apt-setup/universe || true
  55.         ;;
  56.         3)
  57.             db_input low apt-setup/multiverse || true
  58.         ;;
  59.         4)
  60.             db_input low apt-setup/backports || true
  61.         ;;
  62.         5)
  63.             if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
  64.                (db_get apt-setup/multiverse && [ "$RET" = true ]); then
  65.                 db_input low apt-setup/partner || true
  66.             fi
  67.         ;;
  68.         *)
  69.             break
  70.         ;;
  71.     esac
  72.  
  73.     if db_go; then
  74.         STATE=$(($STATE + 1))
  75.     else
  76.         STATE=$(($STATE - 1))
  77.     fi
  78. done
  79. if [ $STATE -eq 0 ]; then
  80.     exit 10
  81. fi
  82.  
  83. dists="main"
  84. alldists="main"
  85. db_get apt-setup/restricted
  86. if [ "$RET" = true ]; then
  87.     dists="$dists restricted"
  88.     alldists="$alldists restricted"
  89. else
  90.     # Remove restricted from any previous cdrom entry if necessary.
  91.     for file in $ROOT/etc/apt/sources.list.base \
  92.             $ROOT/etc/apt/sources.list.new; do
  93.         if [ -e "$file" ]; then
  94.             sed -i '/deb cdrom:/s/ restricted//g' "$file"
  95.         fi
  96.     done
  97. fi
  98.  
  99. db_get mirror/protocol
  100. protocol="$RET"
  101. db_get mirror/codename
  102. codename="$RET"
  103. db_get mirror/$protocol/hostname
  104. hostname="$RET"
  105. db_get mirror/$protocol/directory
  106. directory="/${RET#/}"
  107.  
  108. # Awful hack. Source for ports architectures is only available on
  109. # archive.ubuntu.com, not ports.ubuntu.com.
  110. if [ "$hostname" = ports.ubuntu.com ]; then
  111.     srchostname=archive.ubuntu.com
  112.     srcdirectory=/ubuntu
  113. else
  114.     srchostname="$hostname"
  115.     srcdirectory="$directory"
  116. fi
  117.  
  118. if [ "$protocol" = http ]; then
  119.     db_get mirror/$protocol/proxy
  120.     proxy="$RET"
  121.     if [ -n "$proxy" ]; then
  122.         if ! grep -iq "Acquire::$protocol::Proxy" $ROOT/etc/apt/apt.conf.new; then
  123.             echo "Acquire::$protocol::Proxy \"$proxy\";" >> $ROOT/etc/apt/apt.conf.new
  124.         fi
  125.     fi
  126. fi
  127.  
  128. db_get apt-setup/proposed
  129. PROPOSED="$RET"
  130.  
  131. cat >> $file <<EOF
  132. # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
  133. # newer versions of the distribution.
  134.  
  135. deb $protocol://$hostname$directory $codename $dists
  136. deb-src $protocol://$srchostname$srcdirectory $codename $dists
  137.  
  138. ## Major bug fix updates produced after the final release of the
  139. ## distribution.
  140. deb $protocol://$hostname$directory $codename-updates $dists
  141. deb-src $protocol://$srchostname$srcdirectory $codename-updates $dists
  142. EOF
  143. if [ "$PROPOSED" = true ]; then
  144.     cat >> $file <<EOF
  145.  
  146. ## Proposed updates undergoing testing.
  147. deb $protocol://$hostname$directory $codename-proposed $dists
  148. deb-src $protocol://$srchostname$srcdirectory $codename-proposed $dists
  149. EOF
  150. fi
  151.  
  152. # Even if universe isn't enabled, we write example lines for it.
  153. echo >> $file
  154. if db_get apt-setup/universe && [ "$RET" = true ]; then
  155.     alldists="$alldists universe"
  156.     COMMENT=
  157. else
  158.     cat >> $file <<EOF
  159. ## Uncomment the following two lines to add software from the 'universe'
  160. ## repository.
  161. EOF
  162.     COMMENT='# '
  163. fi
  164. cat >> $file <<EOF
  165. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
  166. ## team. Also, please note that software in universe WILL NOT receive any
  167. ## review or updates from the Ubuntu security team.
  168. ${COMMENT}deb $protocol://$hostname$directory $codename universe
  169. ${COMMENT}deb-src $protocol://$srchostname$srcdirectory $codename universe
  170. ${COMMENT}deb $protocol://$hostname$directory $codename-updates universe
  171. ${COMMENT}deb-src $protocol://$srchostname$srcdirectory $codename-updates universe
  172. EOF
  173. if [ "$PROPOSED" = true ]; then
  174.     cat >> $file <<EOF
  175. ${COMMENT}deb $protocol://$hostname$directory $codename-proposed universe
  176. ${COMMENT}deb-src $protocol://$srchostname$srcdirectory $codename-proposed universe
  177. EOF
  178. fi
  179.  
  180. # Multiverse is different, don't write anything unless enabled.
  181. if db_get apt-setup/multiverse && [ "$RET" = true ]; then
  182.     alldists="$alldists multiverse"
  183.     cat >> $file <<EOF
  184.  
  185. ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
  186. ## team, and may not be under a free licence. Please satisfy yourself as to 
  187. ## your rights to use the software. Also, please note that software in 
  188. ## multiverse WILL NOT receive any review or updates from the Ubuntu
  189. ## security team.
  190. deb $protocol://$hostname$directory $codename multiverse
  191. deb-src $protocol://$srchostname$srcdirectory $codename multiverse
  192. deb $protocol://$hostname$directory $codename-updates multiverse
  193. deb-src $protocol://$srchostname$srcdirectory $codename-updates multiverse
  194. EOF
  195.     if [ "$PROPOSED" = true ]; then
  196.         cat >> $file <<EOF
  197. deb $protocol://$hostname$directory $codename-proposed multiverse
  198. deb-src $protocol://$srchostname$srcdirectory $codename-proposed multiverse
  199. EOF
  200.     fi
  201. fi
  202.  
  203. # Even if the backports repository isn't enabled, we write example lines for
  204. # it.
  205. echo >> $file
  206. if db_get apt-setup/backports && [ "$RET" = true ]; then
  207.     COMMENT=
  208. else
  209.     cat >> $file <<EOF
  210. ## Uncomment the following two lines to add software from the 'backports'
  211. ## repository.
  212. EOF
  213.     COMMENT='# '
  214. fi
  215. cat >> $file <<EOF
  216. ## N.B. software from this repository may not have been tested as
  217. ## extensively as that contained in the main release, although it includes
  218. ## newer versions of some applications which may provide useful features.
  219. ## Also, please note that software in backports WILL NOT receive any review
  220. ## or updates from the Ubuntu security team.
  221. ${COMMENT}deb $protocol://$hostname$directory $codename-backports $alldists
  222. ${COMMENT}deb-src $protocol://$srchostname$srcdirectory $codename-backports $alldists
  223. EOF
  224.  
  225. if (db_get apt-setup/restricted && [ "$RET" = true ]) || \
  226.    (db_get apt-setup/multiverse && [ "$RET" = true ]) || \
  227.    (db_get apt-setup/partner && [ "$RET" = true ]); then
  228.     echo >> $file
  229.     if db_get apt-setup/partner && [ "$RET" = true ]; then
  230.         COMMENT=
  231.     else
  232.         cat >> $file <<EOF
  233. ## Uncomment the following two lines to add software from Canonical's
  234. ## 'partner' repository.
  235. EOF
  236.         COMMENT='# '
  237.     fi
  238.     cat >> $file <<EOF
  239. ## This software is not part of Ubuntu, but is offered by Canonical and the
  240. ## respective vendors as a service to Ubuntu users.
  241. ${COMMENT}deb http://archive.canonical.com/ubuntu $codename partner
  242. ${COMMENT}deb-src http://archive.canonical.com/ubuntu $codename partner
  243. EOF
  244. fi
  245.  
  246. apt-setup-signed-release archive.ubuntu.com "$file"
  247.  
  248. exit 0
  249.